package com.lap.generator.infrastructure.query;

import com.lap.generator.config.model.JdbcInfo;
import com.lap.generator.infrastructure.query.strategy.MetadataDialect;
import com.lap.generator.infrastructure.query.strategy.MySQLMetadataDialect;
import com.lap.generator.infrastructure.query.strategy.OracleMetadataDialect;
import com.lap.generator.infrastructure.query.strategy.PostgreSQLMetadataDialect;

public class MetadataDialectFactory {

  public static MetadataDialect resolve(JdbcInfo jdbcInfo) {
    String jdbcUrl = jdbcInfo.getUrl().toLowerCase();
    if (jdbcUrl.startsWith("jdbc:mysql:")) {
      return new MySQLMetadataDialect();
    } else if (jdbcUrl.startsWith("jdbc:postgresql:")) {
      return new PostgreSQLMetadataDialect();
    } else if (jdbcUrl.startsWith("jdbc:oracle:")) {
      return new OracleMetadataDialect();
    } else {
      throw new UnsupportedOperationException("不支持的数据库类型: " + jdbcUrl);
    }
  }
}
